package com.njzxw.yoga.yogaApi.repository;

import com.njzxw.fs.commonutil.db.ZxwLangDriver;
import org.apache.ibatis.annotations.*;
import com.njzxw.yoga.yogaApi.bean.TeacherAttrBean;


import java.util.List;
import java.util.Map;

@Mapper
public interface TeacherAttrRepository {

    @Select("select e.name oper_name,a.id,a.manage_id,a.support_ptrainer,a.ptrainer_scheduling,a.class_type,a.see_tel,a.limit_classes,a.classes,a.league_fee,a.limit_attend_classes,a.attend_classes," +
            "       a.teacher_info,a.price,a.merchant_id,a.shop_id,a.oper_id,DATE_FORMAT(a.oper_date,'%Y-%m-%d %T') oper_date,a.private_classes " +
            "  from t_teacher_attr a left join t_manager_user e on a.oper_id = e.id " +
            "  where 1=1 and a.manage_id like #{manage_id} " +
            "    and a.support_ptrainer = #{support_ptrainer} " +
            "    and a.ptrainer_scheduling = #{ptrainer_scheduling} " +
            "    and a.class_type = #{class_type} " +
//            "    and a.see_tel = #{see_tel} " +
//            "    and a.limit_classes = #{limit_classes} " +
            "    and a.classes = #{classes} " +
//            "    and a.league_fee like #{league_fee} " +
//            "    and a.limit_attend_classes = #{limit_attend_classes} " +
//            "    and a.attend_classes = #{attend_classes} " +
//            "    and a.teacher_info like #{teacher_info} " +
            "    and a.merchant_id = #{merchant_id} " +
            "    and a.shop_id = #{shop_id} " +
            "    and DATE_FORMAT(a.oper_date,'%Y-%m-%d %T') >= #{min_oper_date} " +
            "    and DATE_FORMAT(a.oper_date,'%Y-%m-%d %T') <= #{max_oper_date} " +
            "    and a.private_classes = #{private_classes} order by oper_date desc")
    @Lang(ZxwLangDriver.class)
    List<Map<String,Object>> queryPage(TeacherAttrBean teacherAttrBean);

    @Select("select e.name oper_name,a.id,a.manage_id,a.support_ptrainer,a.ptrainer_scheduling,a.class_type,a.see_tel,a.limit_classes,a.classes,a.league_fee,a.limit_attend_classes,a.attend_classes,a.teacher_info,a.price,a.merchant_id,a.shop_id,a.oper_id,DATE_FORMAT(a.oper_date,'%Y-%m-%d %T') oper_date,DATE_FORMAT(a.update_oper_id,'%Y-%m-%d %T') update_oper_id,DATE_FORMAT(a.update_oper_date,'%Y-%m-%d %T') update_oper_date,a.private_classes from t_teacher_attr a left join t_manager_user e on a.oper_id = e.id where a.id = #{id}")
    Map<String,Object> queryId(TeacherAttrBean teacherAttrBean);

    @Update("update t_teacher_attr a (#{teacherAttrBean}) where  a.id = #{id}")
    @Lang(ZxwLangDriver.class)
    Integer update(TeacherAttrBean teacherAttrBean);

    @Delete("delete a from t_teacher_attr a where  a.id in (#{ids})")
    @Lang(ZxwLangDriver.class)
    Integer delete(TeacherAttrBean teacherAttrBean);

    @Insert("insert into t_teacher_attr(#{teacherAttrBean})")
    @Lang(ZxwLangDriver.class)
//    @Options(useGeneratedKeys = true)
    Integer insert(TeacherAttrBean teacherAttrBean);


    @Insert("insert into t_manager_user(#{teacherAttrBean})")
    @Lang(ZxwLangDriver.class)
    @Options(useGeneratedKeys = true)
    Integer insertMangerUser(TeacherAttrBean teacherAttrBean);

}

